From: Wei Liu Date: Sat, 2 Jul 2016 11:35:30 +0000 (+0100) Subject: libxl/netbsd: check num_exec in hotplug function X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~828 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=db59dbc46e0312a38978d22c6bd72b554a2f1c91;p=xen.git libxl/netbsd: check num_exec in hotplug function This basically replicates the same logic in libxl_linux.c but with one change -- only test num_exec == 0 in nic hotplug case because NetBSD let QEMU call a script itself. Without this patch libxl will loop indefinitely trying to execute hotplug script. Reported-by: John Nemeth Signed-off-by: Wei Liu Acked-by: Roger Pau Monné --- diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c index 096c0578fc..a79b8aae2b 100644 --- a/tools/libxl/libxl_netbsd.c +++ b/tools/libxl/libxl_netbsd.c @@ -68,7 +68,28 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev, switch (dev->backend_kind) { case LIBXL__DEVICE_KIND_VBD: + if (num_exec != 0) { + LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec); + rc = 0; + goto out; + } + rc = libxl__hotplug(gc, dev, args, action); + if (!rc) rc = 1; + break; case LIBXL__DEVICE_KIND_VIF: + /* + * If domain has a stubdom we don't have to execute hotplug scripts + * for emulated interfaces + * + * NetBSD let QEMU call a script to plug emulated nic, so + * only test if num_exec == 0 in that case. + */ + if ((num_exec != 0) || + (libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) { + LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec); + rc = 0; + goto out; + } rc = libxl__hotplug(gc, dev, args, action); if (!rc) rc = 1; break;